
/*****************************************************************************
 *
 * 作   者: 马婷婷 * 创建时间: 2020/12/15 15:45:04 *
 * Copyright (C) 2008 - 鹏业软件公司
 *
 *****************************************************************************/

import {DataPacket, NorDataList} from 'pengesoft-ng-lib';

/**
 * 薪酬变动记录
 */
export class SalaryRecord extends DataPacket {
  Id: number; // 序号
  EmpId: string; // 员工编号
  OldSalary: number; // 变动前的薪酬
  NewSalary: number; // 变动后的薪酬
  ChangeTime: Date | string; // 变动时间
  ChangeReason: string; // 变动原因

  constructor(options: {
    Id?: number;
    EmpId?: string;
    OldSalary?: number;
    NewSalary?: number;
    ChangeTime?: Date | string;
    ChangeReason?: string;
  } = {}) {
    super();
    this.Id = !options.Id ? 0 : Number.parseFloat(options.Id.toString());
    this.EmpId = options.EmpId || '';
    this.OldSalary = !options.OldSalary ? 0 : Number.parseFloat(options.OldSalary.toString());
    this.NewSalary = !options.NewSalary ? 0 : Number.parseFloat(options.NewSalary.toString());
    this.ChangeTime = this.newDate(options.ChangeTime);
    this.ChangeReason = options.ChangeReason || '';
  }
}

/**
 * 薪酬变动记录列表
 */
export class SalaryRecordList extends NorDataList<SalaryRecord> {

  constructor(options: {
    _Items?: Array<SalaryRecord>
  } = {}) {
    super();
    if (options._Items) {
      for (const item of options._Items) {
        this.append(new SalaryRecord(item));
      }
    }
  }
}
